<%--
    Document   : maptable
    Created on : Oct 29, 2011, 1:17:07 AM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*,Beans.ThamSoHT,Models.ThamSoHT_Model,Models.Ban_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            Vector v = (Vector) request.getAttribute("DSBan");
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = "  'notice', 'rightmsg', 'searchseat' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String notice = mdsts[0].getTenTS();
            String rightmsg = mdsts[1].getTenTS();
            String searchseat = mdsts[2].getTenTS();
            String msgright = notice + "/" + rightmsg;
            int numpage = 0;// khởi tạo số trang = 0
            int vsize = v.size();
            if (vsize % 30 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 30;
            } else {
                numpage = vsize / 30 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String makv = (String) request.getAttribute("makv");
            String soghe = (String) request.getAttribute("soghe");
            if(soghe.equals("all")){
                soghe = "";
            }
%>
            
<div class="bloc">
    <div class="seat">
        <form action="" name="seat">
            <input type="textbox" name="searchseat" class="searchseat" id="1" lang="<%=msgright%>" onclick="ClickSearchSeat()" onkeyup="SearchSeat(this.value, this.alt, this.id, this.lang)" value="<%=soghe%>" alt="<%=makv%>" onkeypress="return keypress(event)"><br/>
            <%          if (v.size() > 0) {%>
            <%
                            for (int i = (item - 1) * 30; i < (item - 1) * 30 + 30 && i < vsize; i++) {
                                Beans.Ban b = (Beans.Ban) v.elementAt(i);
            %>
            <%
                                            if (b.getMaTTBan() == 1) {%>
            <a href="#" class="available" onclick="ShowDatBan(this.name, this.id)" id="<%=b.getTenBan()%>" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>"  ><center><%=b.getTenBan()%></center></a>
            <%  } else if (b.getMaTTBan() == 2) {%>
            <a href="#" class="notbill" onclick="ShowDatBan(this.name, this.id)" id="<%=b.getTenBan()%>" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" ><center><%=b.getTenBan()%></center></a>
            <%  } else if (b.getMaTTBan() == 3) {%>
            <a href="#" class="inbill" onclick="ShowDatBan(this.name, this.id)" id="<%=b.getTenBan()%>" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>"><center><%=b.getTenBan()%></center></a>
            <%  } else if (b.getMaTTBan() == 4) {%>
            <a href="#" class="num paid" onclick="ShowDatBan(this.name, this.id)" id="<%=b.getTenBan()%>" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" ><center><%=b.getTenBan()%></center></a>
            <%  } else if (b.getMaTTBan() == 5) {%>
            <a href="#" class="num cleanup" onclick="ShowDatBan(this.name, this.id)" id="<%=b.getTenBan()%>" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" ><center><%=b.getTenBan()%></center></a>
            <%  } else if (b.getMaTTBan() == 6) {%>
            <a href="#" class="num join" onclick="ShowDatBan(this.name, this.id)" id="<%=b.getTenBan()%>" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" ><center><%=b.getTenBan()%></center></a>
            <%  } else if (b.getMaTTBan() == 7) {%>
            <a href="#" class="num booked" onclick="ShowDatBan(this.name, this.id)" id="<%=b.getTenBan()%>" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>" ><center><%=b.getTenBan()%></center></a>
            <%  } else {%>
            <a href="#" class="num check" onclick="ShowDatBan(this.name, this.id)" id="<%=b.getTenBan()%>" title="<%=Ban_Model.LayTinhTrang(b.getMaBan(), langid)%>" name="<%=b.getMaBan()%>"><center><%=b.getTenBan()%></center></a>
            <%  }%>
            <%  }%>            
            </form>
        <div class="pagination" style=" margin-bottom: 0; margin-top: 0;">
            <%
                    int trang = 1;
                    if (item > 1) {
                        trang = item - 1;
                    }
            %>
            <%  if (vsize > 30) {%>
            <a href="#" class="prev" name="<%=makv%>" id="<%=soghe %>"  title="<%= trang%>" lang="<%=msgright%>" onclick="SearchSeat(this.id, this.name, this.title, this.lang)">«</a>
            <%
                            for (int c = 1; c <= numpage; c++) {

                                if (c != item) {
            %> <a href="#" name="<%= makv%>" title="<%= c%>" id="<%=soghe %>" lang="<%=msgright%>" onclick="SearchSeat(this.id, this.name, this.title, this.lang)" ><%= c%></a>
            <% } else {%><a class="current"> <%= c%></a> <% }
                            }
            %>
            <%
                            if (item + 1 <= numpage) {
                                trang = item + 1;
                            } else {
                                trang = item;
                            }
            %>
            <a href="#" class="next" name="<%= makv%>" id="<%=soghe %>" title="<%= trang%>" lang="<%=msgright%>" onclick="SearchSeat(this.id, this.name, this.title, this.lang)">»</a>
            <%  }%>            
        </div>
    </div>
</div>
<%  }%>